/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package comunicacaoCorba;

import java.util.Properties;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;

/**
 *
 * @author Anderson
 */
public class MainCorbaClient {
    static MainCorba mainCorba;
    public static void main(String args[])
    {
        try
        {
            Properties props = new Properties();
            props.put("org.omg.CORBA.ORBInitialPort", "1050");
            props.put("org.omg.CORBA.ORBInitialHost", "localhost");
            ORB orb = ORB.init(args, props);
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
            String name = "MainCorba";
            mainCorba = MainCorbaHelper.narrow(ncRef.resolve_str(name));
            System.out.println("Obtido um processo no objeto servidor: " + mainCorba);
            //System.out.println(mainCorba.cadastrarCliente("blzblzblz", "sldfakj", "-1", "", "Lkj", "Lkj", "Lkj", "lkj", "anderson","oxente", "lkj", "Lkj", "Lkj"));
            //System.out.println(mainCorba.removerClinte("","blzblzblz","","","","","","","","","","","",""));
            System.out.println(mainCorba.getProdutos(1, -1,-1,-1,"",""));
        }
        catch(Exception e)
        {
            System.out.println("Error: " + e);
            e.printStackTrace();
        }
    }
}
